package com.summer.framework.core.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.summer.framework.base.result.SummerPage;

import java.util.List;
import java.util.function.Function;

/**
 * Description: 分页工具类
 * @auther Ice Yang
 * Date 2025/9/16 17:53
 */
public class PageUtil {

    public static <T,P> SummerPage<T> toPage(Page<P> page, Function<List<P>, List<T>> function) {
        SummerPage<T> newPage = new SummerPage<>();
        newPage.setCurrent(page.getCurrent());
        newPage.setSize(page.getSize());
        newPage.setTotal(page.getTotal());
        newPage.setRecords(function.apply(page.getRecords()));
        return newPage;
    }
}
